package com.itheima.controller;

import com.itheima.domain.Patient;
import com.itheima.service.PatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("/patient")
public class PatientController {
    @Autowired
    private PatientService patientService;

    @RequestMapping("findAll")
    public ModelAndView findAll(ModelAndView modelAndView){
        List<Patient> patientList = patientService.findAll();
        modelAndView.addObject("patientList",patientList);
        modelAndView.setViewName("patients-list");
        return modelAndView;
    }
}
